using UnityEngine;
using UnityEditor;
using Newtonsoft.Json.Linq;

public class ParseCamera : ParseObjectHandle<Camera>
{
    public override void Prase(ExportSetting ExportSetting, Camera obj, JArray jArray)
    {
        var cccemara = ExportSetting.CocosObjectConfig["cc.Camera"].DeepClone();
        if (obj.orthographic)
        {
            cccemara["_projection"] = 0;
        }
        else
        {
            cccemara["_projection"] = 1;
        }
        cccemara["_fov"] = obj.fieldOfView;
        cccemara["_orthoHeight"] = obj.orthographicSize;
        cccemara["_near"] = obj.nearClipPlane;
        cccemara["_far"] = obj.farClipPlane;
        cccemara["_color"] = AssetHelper.TransforCCObject(obj.backgroundColor);
        cccemara["_priority"] = obj.depth;
        switch (obj.clearFlags)
        {
            case CameraClearFlags.Skybox:
                cccemara["_clearFlags"] = 14;
                break;
            case CameraClearFlags.SolidColor:
                cccemara["_clearFlags"] = 7;
                break;
            case CameraClearFlags.Depth:
                cccemara["_clearFlags"] = 6;
                break;
            case CameraClearFlags.Nothing:
                cccemara["_clearFlags"] = 0;
                break;
                // case CameraClearFlags.Skybox:
                //     break;
        }
        cccemara["_rect"] = AssetHelper.TransforCCObject(obj.rect);
        SerializedObject serializedObject = new SerializedObject(obj);
        var intV = serializedObject.FindProperty("m_FOVAxisMode").intValue;
        cccemara["_fovAxis"] = intV;
        jArray.Add(cccemara);
    }
}